package io.zim.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.zim.common.utils.PageUtils;
import io.zim.common.utils.Query;
import io.zim.common.utils.StringUtil;
import io.zim.modules.app.dao.ApiShopMapper;
import io.zim.modules.app.entity.ShopVo;
import io.zim.modules.app.service.ApiShopService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 *商铺服务实现类
 */
@Service("apiShopService")
public class ApiShopServiceImpl extends ServiceImpl<ApiShopMapper,ShopVo> implements ApiShopService {
  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    Long userId = (Long)params.get("userId");
    Long referrer = (Long)params.get("referrer");
    Integer status = (Integer)params.get("status");
    Page<ShopVo> page = (Page<ShopVo>) this.page(
        new Query<ShopVo>(params).getPage(),
        new QueryWrapper<ShopVo>()
            .eq(!StringUtil.isNullOrEmpty(userId),"user_id", userId)
            .eq(!StringUtil.isNullOrEmpty(referrer),"referrer", referrer)
            .eq(!StringUtil.isNullOrEmpty(status),"status", status)
    );
    return new PageUtils(page);
  }
}
